<?php 
if(set_value('post_category')){
	$selected_category = set_value('post_category');
}
elseif(isset($post[0]['post_category'])){
	$selected_category = $post[0]['post_category'];
}
else{
	$selected_category = '';
}
foreach($category as $key => $val){
	
?>
	<?php if( $selected_category == $val['category_key']){ ?>

		<option value="<?php echo $val['category_key'] ?>" selected="selected"><?php echo $val['category_value'] ?></option>

	<?php }else{ ?>
		<option value="<?php echo $val['category_key'] ?>"><?php echo $val['category_value'] ?></option>
	<?php } ?>
<?php
}
?>